import { request } from '@/utils/request'

export interface StripePaymentIntentResponseData {
  customer: string;
  ephemeralKey: string;
  order_id: string;
  paymentIntent: string;
  publishableKey: string;
}

export interface StripeApiResponse {
  code: number;
  msg: string;
  time: number;
  data: StripePaymentIntentResponseData;
}

export const createStripePaymentIntentApi = (data: {
  currency: string
  amount: string
  order_id: string
}) => {
  return request<StripeApiResponse>( // Using the more specific StripeApiResponse
    {
      method: 'POST',
      url: '/api/stripe/app/pay/create',
      data,
    },
    false, // Assuming this API doesn't require authentication, adjust if needed
  )
}

export const createPaymentApi = (data: {
  pay_way: string  // pay_way balance 是 String 支付方式：wxpay=微信，balance=余额
  id: string
}) => {
  return request<StripeApiResponse>( // Using the more specific StripeApiResponse
    {
      method: 'POST',
      url: '/order/pay',
      data,
      header: {
        'source-client': 'mobile'
      }
    },
    false, // Assuming this API doesn't require authentication, adjust if needed
  )
}
